local skel = fk.CreateSkill {
  name = "lb_zero__beixi",
}

Fk:loadTranslationTable {
  ["lb_zero__beixi"] = "背袭",
  [":lb_zero__beixi"] = "每名角色限一次，当你响应或使用牌后，你可以对一名没有手牌的角色造成2点伤害。",

  ["#lb_zero__beixi"] = "背袭：你可以对一名没有手牌的角色造成2点伤害（每名角色限一次）",
  ["@[player]lb_zero__beixi"] = "背袭",

  ["$lb_zero__beixi1"] = "到处都是破绽！",
  ["$lb_zero__beixi2"] = "就决定是你啦！",
  ["$lb_zero__beixi3"] = "来磨爪子喽！",
}

local beixi_spec = {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if data.responseToEvent and not data.responseToEvent.from then
      return false
    end
    return player:hasSkill(skel.name) and target == player and
        table.find(player.room.alive_players, function(to)
          return to:isKongcheng() and not table.contains(player:getTableMark("@[player]lb_zero__beixi"), to.id)
        end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = table.filter(room:getAlivePlayers(), function(to)
      return to:isKongcheng() and not table.contains(player:getTableMark("@[player]lb_zero__beixi"), to.id)
    end)
    if #tos == 0 then return end
    tos = room:askToChoosePlayers(target, {
      targets = tos,
      min_num = 1,
      max_num = 1,
      skill_name = skel.name,
      prompt = "#lb_zero__beixi",
      cancelable = true,
    })
    if #tos > 0 then
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    room:addTableMark(player, "@[player]lb_zero__beixi", to.id)
    room:damage {
      from = player,
      to = to,
      damage = 2,
      damageType = fk.NormalDamage,
      skillName = skel.name,
    }
  end,
}

skel:addEffect(fk.CardUseFinished, beixi_spec)
skel:addEffect(fk.CardRespondFinished, beixi_spec)

return skel
